﻿#ifndef PLAYER_H
#define PLAYER_H

#include <QWidget>
#include<QFileDialog>
#include <QFileInfo>
#include <QMediaPlayer>
#include<QListWidgetItem>
#include <QMediaPlaylist>
#include<QStringList>
#include<QMovie>
#include <QMainWindow>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QStandardItemModel>
#include<QDebug>
#include<QTimer>
namespace Ui {
class Player;
}

struct song
{
    QString songname;//歌名
    QString singer;//歌手
    QString album_name;//专辑
    int duration2;//时间
    int music_id;//音乐id
};


class Player : public QWidget
{
    Q_OBJECT

public:
    explicit Player(QWidget *parent = nullptr);
    ~Player();
    void parseJson(QByteArray jsonByte);
    QString formatDuration(int durationInSeconds);
public slots:
    void replyFinished(QNetworkReply *reply);

private slots:
    void on_load_pushButton_clicked();

    void onPlayPauseButtonClicked();

    void on_next_toolButton_clicked();

    void on_back_toolButton_clicked();

    void on_paly_mode_currentTextChanged(const QString &arg1);

    void on_listWidget_currentRowChanged(int currentRow);

    void on_delete_pushButton_clicked();

    void on_grep_pushButton_clicked();

    void on_tableView_clicked(const QModelIndex &index);

    void on_volume_valueChanged(int value);

    void on_schedule_sliderMoved(int position);

    void on_postionChanged(qint64 position);

    void on_durationChanged(qint64 duration);
    void updatePosition();

private:
    Ui::Player *ui;
    QStringList items;
    QMediaPlayer *player;
    QMediaPlaylist *playerlist;
    QMovie *movie;
    QNetworkAccessManager *manager;
    QStandardItemModel *pModel;
    QStringList titles;
    QList<song>song_list;
    QTimer *timer;//定时器
};

#endif // PLAYER_H
